<% if @success %>
  if($('.favorite_link').length) {
    $('.favorite_link').attr('href', '<%= favorite_products_path(:id => @favorite.product_id) %>').data('method', 'post').text('<%= Spree.t(:mark_as_favorite) %>')
    alert('Successfully unmarked as favorite');
  } else {
    $("#favorite_product_<%= @favorite.product_id%>").remove();
    alert("Successfully removed favorite product from your list");
    if (!$('.favorite_product').length) {
      window.location = '<%= favorite_products_path %>'
    }
  }
<% else %>
  alert("Could not remove product form your list")
<% end %>